<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' ); 

$db =& JFactory::getDBO();
$user =& JFactory::getUser();

$db->setQuery("select * from `wed_contacts` where `user_id` = '".$user->id."' order by `id`");
$contacts = $db->loadObjectList();

?>
<link rel="stylesheet" href="<?php echo JRoute::_('/modules/mod_wed_contacts/style.css'); ?>" type="text/css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script type="text/javascript" src="<?php echo JRoute::_('/modules/mod_wed_contacts/wed_contacts.js'); ?>"></script>
<table id="contacts_table">
	<tr>
		<td width='25px'>№</td>
		<td width='100px'>Вид услуг</td>
		<td width='150px'>Ф.И.О./Название организации</td>
		<td width='150px'>Телефон, Адрес</td>
		<td>Комментарий</td>
		<td width='50px'>Удалить</td>
	</tr>
	<?php
	$i = 1;
	foreach ($contacts as $contact) {
		echo "<tr class='contact'>";
		echo "<td class='td-center contact-number'>".($i++)."</td>";
		echo "<td><input type='text' class='service' value='{$contact->service}' /></td>";
		echo "<td><input type='text' class='name' value='{$contact->name}' /></td>";
		echo "<td><input type='text' class='contacts' value='{$contact->contacts}' /></td>";
		echo "<td><textarea class='comment' >{$contact->comment} </textarea></td>";
		echo "<td><input type='button' class='contact_delete' value='Удалить' /></td>";
		echo "</tr>";
	}
	?>
	<tr>
		<td colspan="6" class="td-center">
			<input type="button" id="add-contact" value="Добавить" />
		</td>
	</tr>
	<tr>
		<td colspan="6">
			<input type="button" id="contacts-save" value="Сохранить" />
			<span id="save_result"></span>
		</td>
	</tr>
</table>